import { Behaviour, core, SerilizeField, propertyEditor_String } from "../gameengine";

import { user } from "../user";
import { marshal, MarshalEndingState } from "../Marshal";


export class GamingBehaviour extends Behaviour {
    @SerilizeField(propertyEditor_String)

    public prefab: string;


    private duringTime:number = 0;

   
    protected onStart() {
        core.loadPrefab(`assets/${this.prefab}.prefab.json`, (prefabGameObject) => {

            this.displayObject.addChild(prefabGameObject);
        })
       const audio = new Audio;
       audio.loop= true ;
       audio.src= 'assets/bgm.mp3'
       audio.play();

    }

    protected onUpdate(advancedTime: number) {

        
        //this.duringTime += advancedTime;
        // if (this.duringTime >= 3000){
        //     console.log('游戏结束')
        //     marshel.changeState(new MarshelLandingState());
        // }
        // user.score++;
        // console.log (user.score)
       // user.hp -= 1;
       // if (user.hp <= 0){
           // marshal.changeState(new MarshalEndingState());
       // }
        //console.log (user.hp)


    }

}